//
//  LBDiscussAVTopView.m
//  LBTILiveSDK_Example
//
//  Created by 刘文扬 on 2018/4/27.
//  Copyright © 2018年 刘文扬. All rights reserved.
//

#import "LBDiscussAVTopView.h"
#import <Masonry.h>
#import <UIButton+LBStyle.h>
#import <UIColor+LBColor.h>

@implementation LBDiscussAVTopView

-(instancetype)init
{
    self = [super init];
    if (self) {
        
        [self initSubviews];
        
        
    }
    return self;
}


-(void)initSubviews
{
    [self addSubview:self.avNameLabel];
    [self addSubview:self.avTimeLabel];
    [self addSubview:self.finishButton];
    [self addSubview:self.detailButton];
    
    
    [self.avNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(0);
        make.leading.offset(20);
    }];
    
    [self.avTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.avNameLabel.mas_bottom).offset(5);
        make.leading.equalTo(self.avNameLabel).offset(0);
    }];
    
    [self.finishButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.avNameLabel.mas_bottom);
        make.trailing.offset(-20);
        make.size.mas_equalTo(CGSizeMake(76, 30));
    }];
    
    [self.detailButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.avNameLabel).offset(0);
        make.top.equalTo(self.avTimeLabel.mas_bottom).offset(10);
        make.bottom.offset(0);
        make.size.mas_equalTo(CGSizeMake(80, 34));
    }];
}

-(UILabel *)avNameLabel
{
    if (_avNameLabel == nil) {
        
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:18];
        label.textColor = [UIColor whiteColor];
        label.numberOfLines = 1;
        _avNameLabel = label;
        
    }
    return _avNameLabel;
}

-(UILabel *)avTimeLabel
{
    if (_avTimeLabel == nil) {
        
        UILabel *label = [[UILabel alloc] init];
        label.font = [UIFont systemFontOfSize:12];
        label.textColor = [UIColor whiteColor];
        label.numberOfLines = 1;
        _avTimeLabel = label;
        
    }
    return _avTimeLabel;
}

-(UIButton *)finishButton
{
    if (_finishButton == nil) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"结束视频" forState:UIControlStateNormal];
        [button setBackgroundColor:[UIColor colorWithRed:250.0/255.0 green:85.0/255.0 blue:85.0/255.0 alpha:1] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        button.layer.cornerRadius = 15;
        button.layer.masksToBounds = YES;
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(finishAV:) forControlEvents:UIControlEventTouchUpInside];
        _finishButton = button;
        
    }
    return _finishButton;
}

-(void)finishAV:(id)sender
{
    
}

-(UIButton *)detailButton
{
    if (_detailButton == nil) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"承包详情" forState:UIControlStateNormal];
        [button setBackgroundColor:[UIColor colorWithRed:0/255 green:0/255 blue:0/255 alpha:0.5] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        button.layer.cornerRadius = 17;
        button.layer.masksToBounds = YES;
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(detailAction:) forControlEvents:UIControlEventTouchUpInside];
        _detailButton = button;
        
    }
    return _detailButton;
}

-(void)detailAction:(id)sender
{
    
}




-(void)updateData
{
    self.avNameLabel.text = @"哈哈哈哈哈";
    self.avTimeLabel.text = @"视频中:5:45";
}

@end
